package com.sunsy.authserver.dao;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sunsy.authserver.beans.po.UserAppRelation;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * (UserAppRelation)表数据库访问层
 *
 * @author makejava
 * @since 2021-07-20 14:40:41
 */
@Mapper
public interface UserAppRelationDao extends BaseMapper<UserAppRelation> {


    @Select("select a.app_name,uar.user_id from user_app_relation uar,app_client a ${ew.customSqlSegment} and uar.app_id = a.id ")
    List<Map<String,Object>> getAppNameByUserId(@Param("ew") Wrapper queryWrapper);

    @Delete("delete from user_app_relation where app_id = #{appId}")
    int delByAppId(Long appId);

    @Select("select user_id from user_app_relation where app_id = #{appId}")
    List<Long> getUserList(Long appId);

}